<template>
  <div>
    <button @click="toLogin">登录{{ url }}-----{{ $num }}</button>
    <button @click="getInfo">获取用户信息</button>
  </div>
</template>
<script>
import { login, sysProfile } from '@/api/test'
export default {
  data () {
    return {
      url: process.env.VUE_APP_URL
    }
  },
  methods: {
    async toLogin () {
      login().then(res => {
        console.log('token存储到localstorage')
        localStorage.setItem('token', res.data.data)
      })
      // .catch(e => {
      //   console.log('catch:', e)
      // })
      // try {
      //   const res = await login()
      //   console.log('token存储到localstorage')
      //   localStorage.setItem('token', res.data.data)
      // } catch (e) {
      //   console.log('catch:', e)
      // }
    },
    async getInfo () {
      const res = await sysProfile()
      alert('获取成功')
      console.log('用户信息', res)
    }
  }
}
</script>
<style></style>
